package reptile

import (
	"regexp"
	"robot/study/LiveRobot/define"
)

var Reb *Rebiao

type Rebiao struct {
	Flag bool
	U    *define.Message2
}

//表情包复读
func (re *Rebiao) Work() {
	pre, _ := regexp.Compile(`(https?)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]`)
	body := pre.FindString(re.U.Message.(string))
	str := "[CQ:image,file=" + body + "]"
	msg := &define.Msg{
		Msg_type: re.U.MessageType,
		Number:   int(re.U.GroupId),
		Msg:      str,
	}
	Sendmsg(msg)
}

//关闭复读鸡
func (re *Rebiao) Workoff() {
	Reb.Flag = false
	ms := &define.Msg{
		Msg_type: "group",
		Number:   define.QUN,
		Msg:      "已关闭复读鸡",
	}
	Sendmsg(ms)
}

//开启复读鸡
func (re *Rebiao) Workopen() {
	Reb.Flag = true
	ms := &define.Msg{
		Msg_type: "group",
		Number:   define.QUN,
		Msg:      "已开启复读鸡",
	}
	Sendmsg(ms)
}
